using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using Planisoft.Entities;



namespace Planisoft.DAO.Mapping
{
    public class ValoresRegPensionarioMap : EntityTypeConfiguration<ValoresRegPensionario>
    {
        public ValoresRegPensionarioMap()
        {
            // Primary Key
            this.HasKey(t => new { t.anio, t.mes, t.fondo, t.comision, t.prima });

            // Properties
            this.Property(t => t.IdRP)
                .IsRequired();


            this.Property(t => t.IdRegPensionario)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.anio)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.mes)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.fondo)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.comision)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.prima)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("ValoresRegPensionario");
            this.Property(t => t.IdRP).HasColumnName("IdRP");
            this.Property(t => t.IdRegPensionario).HasColumnName("IdRegPensionario");
            this.Property(t => t.anio).HasColumnName("anio");
            this.Property(t => t.mes).HasColumnName("mes");
            this.Property(t => t.fondo).HasColumnName("fondo");
            this.Property(t => t.comision).HasColumnName("comision");
            this.Property(t => t.prima).HasColumnName("prima");

            // Relationships
            this.HasRequired(t => t.RegimenPensionario)
                .WithMany(t => t.ValoresRegPensionarios)
                .HasForeignKey(d => d.IdRegPensionario);

        }
    }
}
